﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Crosland.Offline.Logic;
using Crosland.Offline.Core;

namespace Crosland.Offline.WinForm
{
    public partial class Stock : Form
    {
        public Stock()
        {
            InitializeComponent();
        }

        private void Stock_Load(object sender, EventArgs e)
        {
            dgvStock.AutoGenerateColumns = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            VehiculoLogic ve = new VehiculoLogic();

            List<Vehiculo> lstMaterial = new List<Vehiculo>();
            lstMaterial = ve.GetByCriteria(txtMat.Text, txtColor.Text, txtLote.Text, txtStatusV.Text, txtDispo.Text);
            dgvStock.DataSource = lstMaterial;
            dgvStock.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
        }

        private void dgvStock_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                List<Vehiculo> lstMat = new List<Vehiculo>();

                Vehiculo objMat = new Vehiculo();
                lstMat = (List<Vehiculo>)dgvStock.DataSource;
                objMat = lstMat[e.RowIndex];
                lstMaterial.Items.Add(objMat.Vhcle.Trim() + " - " + objMat.Matnr.Trim() + " - " + objMat.ZzcolorDesc.Trim() + " - " + objMat.ZzanoModelo);
            }
        }
    }
}
